package com.ldz.eb.config;

import com.ldz.eb.mapper.EbProductCategoryMapper;
import com.ldz.eb.module.EbProductCategory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.servlet.ServletContext;
import java.util.List;

@Component
public class InitContext implements CommandLineRunner{
    @Resource
    private EbProductCategoryMapper ebPCM;
    @Resource
    private ServletContext application;
    public void run(String... args){
        System.out.println("==spring boot 项目自定义初始化");
        List<EbProductCategory> DadsCategory= ebPCM.selectDadCategory();
        List<EbProductCategory> SonsCategory= ebPCM.selectSonCategory();
        application.setAttribute("DadsCategory",DadsCategory);
        application.setAttribute("SonsCategory",SonsCategory);
    }
}